#include<bits/stdc++.h>
using namespace std;
const int inf = 0x1f1f1f1f,hf = 0x0f0f0f0f,V = 999999;
multiset<int> l[1000011],r[1000011];
typedef struct{
	int mxl,mnr,ans;
}Tree;
Tree t[4000011];
void pushup(int p)
{
	t[p].mxl = max(t[p << 1].mxl,t[p << 1 | 1].mxl);
	t[p].mnr = min(t[p << 1].mnr,t[p << 1 | 1].mnr);
	t[p].ans = min({t[p << 1].ans,t[p << 1 | 1].ans,t[p << 1 | 1].mnr - t[p << 1].mxl + 1});
}
void Get(int p,int pl)
{
	if(!l[pl].empty())
		t[p].mxl = -(*l[pl].begin());
	else
		t[p].mxl = -inf;
	if(!r[pl].empty())
		t[p].mnr = *r[pl].begin();
	else
		t[p].mnr = inf;
	t[p].ans = inf;
}
void upd(int p,int pl,int l,int r)
{
	if(l == r)
		return Get(p,pl);
	int mid = l + r >> 1;
	if(pl <= mid) upd(p << 1,pl,l,mid);
	else upd(p << 1 | 1,pl,mid + 1,r);
	pushup(p);
}
multiset<pair<int,int> > a1,a2;
int Q;
int main()
{
	for(int i = 1;i <= 4 * V;i++) t[i] = {-inf,inf,inf};
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	cin >> Q;
	while(Q--)
	{
		char OPT;
		int x,y;
		cin >> OPT >> x >> y;
		y--;
		if(OPT == 'A')
		{
			l[y].insert(-x),r[x].insert(y);
			a1.insert({y,-x}),a2.insert({-x,y});
		}else{
			l[y].erase(l[y].find(-x)),r[x].erase(r[x].find(y));
			a1.erase(a1.find({y,-x})),a2.erase(a2.find({-x,y}));
		}
		upd(1,x,1,V),upd(1,y,1,V);
		if(t[1].ans <= hf)
			cout << t[1].ans << "\n";
		else
			cout << (*a2.begin()).second + (*a1.begin()).second + 1 << "\n";
	}
	return 0;
}